import Router from 'koa-router';
import proxyService from '../../common/proxyService';
import {
  getTradeOrderByOperation,
  updateTradeOrderApprovalRefuse,
  updateTradeOrderApprovalAdopt,
  getPayOrderDetailForM,
  savePayVoucherTradeOrderM,
  getTXCloudTokenByPayVoucherM,
} from '../../api';
const router = new Router();

//  运营系统获得交易订单列表
router.post('/getTradeOrderByOperation', async ctx => {
  let response = await proxyService.postProxy(ctx, getTradeOrderByOperation);
  return (ctx.body = response);
});

// 运营系统拒绝审批
router.post('/updateTradeOrderApprovalRefuse', async ctx => {
  const response = await proxyService.postProxy(ctx, updateTradeOrderApprovalRefuse);
  return (ctx.body = response);
});

// 运营系统审批通过
router.post('/updateTradeOrderApprovalAdopt', async ctx => {
  const response = await proxyService.postProxy(ctx, updateTradeOrderApprovalAdopt);
  return (ctx.body = response);
});

//  获取交易订单详情
router.post('/getPayOrderDetailForM', async ctx => {
  let response = await proxyService.postProxy(ctx, getPayOrderDetailForM);
  return (ctx.body = response);
});

router.post('/savePayVoucherTradeOrder', async ctx => {
  let response = await proxyService.postProxy(ctx, savePayVoucherTradeOrderM);
  return (ctx.body = response);
});

router.post('/getTXCloudTokenByPayVoucher', async ctx => {
  let response = await proxyService.postProxy(ctx, getTXCloudTokenByPayVoucherM);
  return (ctx.body = response);
});

export default router;
